
from . import flutter
TextStyle = flutter.TextStyle
Container = flutter.Container
Center = flutter.Center
Text = flutter.Text
Stack = flutter.Stack
Positioned = flutter.Positioned
Transform = flutter.Transform
LinearGradient = flutter.LinearGradient
Colors = flutter.Colors
TextAlign = flutter.TextAlign
EdgeInsets = flutter.EdgeInsets
FontWeight = flutter.FontWeight
FontStyle = flutter.FontStyle
BoxShadow = flutter.BoxShadow
BoxShape = flutter.BoxShape
RichText = flutter.RichText
TextSpan = flutter.TextSpan
TextOverflow = flutter.TextOverflow
BorderRadius = flutter.BorderRadius
Offset = flutter.Offset

def 设置容器宽度():
	bold24Roboto = TextStyle(fontSize=24, fontWeight=FontWeight.w900, fontFamily="Georgia")
	return Container(
				child=Center(
					child=Container(
						child=Text(
							"Lorem ipsum", 
							style=bold24Roboto,
							textAlign=TextAlign.center,
						),
						color=Colors.red[400],
						padding=EdgeInsets.all(16),
						width=240,
					),
				),
				width=320,
				height=240,
				color=Colors.grey[300],
			)

def 操控位置与大小():
	bold24Roboto = TextStyle(fontSize=24, fontWeight=FontWeight.w900, fontFamily="Georgia")
	container = Container(
		child=Stack(
			children=[
				Positioned( # red box
					child=Container(
						child=Text(
							"Lorem ipsum",
							style=bold24Roboto,
						),
						color=Colors.red[400],
						padding=EdgeInsets.all(16),
					),
					left=24,
					top=24,
				),
			],
		), 
		width=320,
		height=240,
		color=Colors.grey[300],
	)
	return container

def 旋转元素():
	bold24Roboto = TextStyle(fontSize=24, fontWeight=FontWeight.w900, fontFamily="Georgia")
	container = Container(
		child=Center(
			child=Transform(
				child=Container(
					child=Text(
						"Lorem ipsum",
						style=bold24Roboto,
						textAlign=TextAlign.center,
					),
					color=Colors.red[400],
					padding=EdgeInsets.all(16),
				),
				rotate=15,
			), 
		),
		width=320,
		height=240,
		color=Colors.grey[300],
	)
	return container

def 缩放元素():
	bold24Roboto = TextStyle(fontSize=24, fontWeight=FontWeight.w900, fontFamily="Georgia")
	container = Container(
		child=Center(
			child=Transform(
				child=Container(
					child=Text(
						"Lorem ipsum",
						style=bold24Roboto,
						textAlign=TextAlign.center,
					),
					color=Colors.red[400],
					padding=EdgeInsets.all(16),
				),
				scale=1.5,
			),
		),
		width=320,
		height=240,
		color=Colors.grey[300],
	)
	return container

def 变换():
	bold24Roboto = TextStyle(fontSize=24, fontWeight=FontWeight.w900, fontFamily="Georgia")
	container = Container(
		child=Center(
			child=Container(
				child=Text(
					"Lorem ipsum",
					style=bold24Roboto,
				),
				gradient=LinearGradient(
					degree=90,
					colors=[
						"#ef5350",
						Colors.argb('00000000'),
					],
				),
				padding=EdgeInsets.all(16),
			),
		),
		width=320,
		height=240,
		color=Colors.grey[300],
	)	
	return container

def 圆角():
	bold24Roboto = TextStyle(fontSize=24, fontWeight=FontWeight.w900, fontFamily="Georgia")
	container = Container(
		child=Center(
			child=Container(
				child=Text(
					"Lorem ipsum",
					style=bold24Roboto,
				),
				color=Colors.red[400],
				borderRadius=BorderRadius.all(8),
				padding=EdgeInsets.all(16),
			),
		),
		width=320,
		height=240,
		color=Colors.grey[300],
	)
	return container

def 盒阴影():
	bold24Roboto = TextStyle(
						fontSize=24, 
						fontWeight=FontWeight.w900, 
						fontFamily="Georgia",
					)
	container = Container(
		child=Center(
			child=Container(
				child=Text(
					"Lorem ipsum",
					style=bold24Roboto,
				),
				color=Colors.red[400],
				boxShadow=[
					BoxShadow (
						color=Colors.argb('cc000000'),
						offset=Offset(0, 2),
						blurRadius=4,
					),
					BoxShadow (
						color=Colors.argb('80000000'),
						offset=Offset(0, 6),
						blurRadius=20,
					),
				], 
				padding=EdgeInsets.all(16),
			),
		),
		width=320,
		height=240,
		color=Colors.grey[300],
		margin=EdgeInsets.only(bottom=16),
	)
	return container

def 圆与椭圆():
	bold24Roboto = TextStyle(fontSize=24, fontWeight=FontWeight.w900, fontFamily="Georgia")
	container = Container(
		child=Center(
			child=Container(
				child=Text(
					"Lorem ipsum",
					style=bold24Roboto,
					textAlign=TextAlign.center, 
				),
				color=Colors.red[400],
				padding=EdgeInsets.all(16),
				width=160,
				height=160,
				shape=BoxShape.circle,			),
		),
		width=320,
		height=240,
		color=Colors.grey[300],
	)
	return container

def 操控文本():
	bold24Roboto = TextStyle(
						fontSize=24, 
						fontWeight=FontWeight.w900, 
						fontFamily="Georgia",
						letterSpacing=4,
					)
	container = Container(
		child=Center(
			child=Container(
				child=Text(
					"Lorem ipsum",
					style=bold24Roboto,
				),
				color=Colors.red[400], 
				padding=EdgeInsets.all(16),
			),
		),
		width=320,
		height=240,
		color=Colors.grey[300],
		margin=EdgeInsets.only(bottom=16),
	)
	return container

def 内联样式():
	bold24Roboto = TextStyle(fontSize=24, fontWeight=FontWeight.w900, fontFamily="Georgia")
	container = Container(
		child=Center(
			child=Container(
				child=RichText(
					text=TextSpan(
						style=bold24Roboto,
						children=[
							TextSpan(text="Lorem "),
							TextSpan(
								text="ipsum",
								style=TextStyle(
									fontWeight=FontWeight.w300,
									fontStyle=FontStyle.italic,
									fontSize=48,
								),
							),
						],
					),
				), 
				color=Colors.red[400],
				padding=EdgeInsets.all(16),
			),
		),
		width=320,
		height=240,
		color=Colors.grey[300],
	)
	return container

def 文本摘要():
	bold24Roboto = TextStyle(
						fontSize=24, 
						fontWeight=FontWeight.w900, 
						fontFamily="Georgia",
					)
	container = Container(
		child=Center(
			child=Container(
				child=Text(
					"Lorem ipsum dolor sit amet, consec etur",
					style=bold24Roboto,
					overflow=TextOverflow.ellipsis,
					maxLines=1,
				),
				color=Colors.red[400], 
				padding=EdgeInsets.all(16),
			),
		),
		width=320,
		height=240,
		color=Colors.grey[300],
		margin=EdgeInsets.only(bottom=16),
	)
	return container

def run_app():
	def display(elt): 
		javascript.document.body.appendChild(elt.render())
	display(设置容器宽度())
	display(操控位置与大小())
	display(旋转元素())
	display(缩放元素())
	display(变换())
	display(圆角())
	display(盒阴影())
	display(圆与椭圆())
	display(操控文本())
	display(内联样式())
	display(文本摘要())

